<!DOCTYPE html>
<html lang="en" xmlns:th="https://www.thymeleaf.org/">
<head>
    <title>电影网站</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 0;
            background-color: #f5f5f5;
        }

        header {
            background-color: #e1021f;
            padding: 20px;
            color: #fff;
        }

        h1 {
            margin: 0;
        }

        nav {
            margin-top: 20px;
            display: flex;
            justify-content: center;
            background-color: #333;
        }

        nav a {
            color: #fff;
            text-decoration: none;
            padding: 10px 20px;
        }

        .banner {
            width: 100%;
            height: 300px;
            background-image: url(path_to_image/banner.jpg);
            background-position: center;
            background-size: cover;
        }

        .container {
            max-width: 1200px;
            margin: 20px auto;
            padding: 20px;
        }

        .section {
            margin-bottom: 20px;
        }

        .section-title {
            font-size: 24px;
            margin-bottom: 10px;
        }

        .movie-card {
            display: inline-block;
            width: 200px;
            margin-right: 20px;
            margin-bottom: 20px;
        }

        .movie-card img {
            width: 100%;
            height: 280px;
            object-fit: cover;
            border-radius: 5px;
        }

        .movie-card h3 {
            margin: 10px 0;
            font-size: 16px;
        }

        .movie-card p {
            margin: 0;
            color: #888;
            font-size: 14px;
        }

        .banner-container {
            width: 100%;
            overflow: hidden;
            position: relative;
        }

        .banner-slides {
            display: flex;
            transition: transform 0.5s ease-in-out;
        }

        .banner-slide {
            flex: 0 0 100%;
        }

        .banner-slide img {
            width: 100%;
            height: auto;
        }

        .pagination {
            margin-top: 20px;
            text-align: center;
        }

        .pagination ul {
            list-style-type: none;
            padding: 0;
            display: inline-block;
        }

        .pagination li {
            display: inline-block;
        }

        .pagination a {
            padding: 8px;
            text-decoration: none;
            color: #333;
        }

        .pagination a:hover {
            background-color: #eee;
        }

        .pagination .active a {
            background-color: #4CAF50;
            color: white;
        }

        .pagination .disabled a {
            pointer-events: none;
            background-color: #ddd;
            color: #999;
        }

        .avatar-container {
            position: fixed;
            top: 10px;
            right: 0;
            padding: 10px;
            display: flex;
            align-items: center;
        }

        .avatar {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            margin-right: 10px;
        }

        .name {
            font-weight: bold;
            font-size: 16px;
        }

    </style>
    <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.js"></script>
    <script>
        window.onload = function () {
            console.log($("#userId").text())
            var socket = new WebSocket("ws://localhost:8080/websocket?userId=" + $("#userId").text());

            socket.onopen = function () {
                console.log("WebSocket连接已建立");
            };

            socket.onmessage = function (event) {
                var message = event.data;
                console.log("接收到消息：" + message);
                displayMessage(message);
            };

            socket.onclose = function (event) {
                console.log("WebSocket连接已关闭");
            };

            function displayMessage(message) {
                alert(message);
            }

            function sendMessage() {
                var input = document.getElementById("message-input");
                var message = input.value;
                socket.send(message);
                input.value = "";
            }
        }
    </script>
</head>
<body>
<header>
    <h1>电影网站</h1>

    <div class="avatar-container">
        <img class="avatar" th:src="${touxiang}" alt="头像">
        姓名：<span th:text="${name}" id="userId"/>
        <span th:text="|性别:${sex}|" id="sex"/>
    </div>

</header>
<div class="container">

    <div class="section">
        <h2 class="section-title">热门电影</h2>

        <div class="movie-cards">
            <div class="movie-card" th:each="hotMovie,userStat:${hotOdsMovieInfoList}">
                <img th:src="${hotMovie.url}">
                <h3 th:text="${hotMovie.title}"></h3>
                <p th:text="|评分:${hotMovie.score}|"></p>
                <p th:text="|上映时间:${hotMovie.onlineTime}|"></p>
                <p th:text="|类型:${hotMovie.tags}|"></p>
            </div>

        </div>
    </div>

    <div class="section">
        <h2 class="section-title">猜你喜欢</h2>

        <div class="movie-cards">
            <div class="movie-card" th:each="movie,userStat:${odsMovieInfoList}">
                <img th:src="${movie.url}">
                <h3 th:text="${movie.title}"></h3>
                <p th:text="|上映时间:${movie.onlineTime}|"></p>
                <p th:text="|类型:${movie.tags}|"></p>
            </div>
            <!-- 添加更多电影卡片... -->
        </div>

        <div class="pagination">
            <ul>
                <li th:if="${page.hasPrevious()}">
                    <a th:href="@{|/ods-movie-info/index?pageNum=${page.current-1}|}">上一页</a>
                </li>
                <li th:if="${page.hasNext()}">
                    <a th:href="@{|/ods-movie-info/index?pageNum=${page.current+1}|}">下一页</a>
                </li>
            </ul>
        </div>

    </div>

</div>
</body>
</html>
